<script>
function returnResultObject(obj){
	//var obj = {id:val_id,name:val_name};
	
	window.opener["<?php echo $callback ?>"](obj);
	window.close();
}

$(function(){
		var dataList = <?php echo $jsonListData;?>		
		var numberTemplate = {formatter: 'number', align: 'right', sorttype: 'number'};	 
		$("#tblData").jqGrid({
			datatype: 'jsonstring',
			datastr: dataList,
			loadonce:true,
			mtype:"GET",
			autowidth:true,
			height:"100%",
			altRows:true,
			ignoreCase:true,			
			colModel: [
				<?php
					foreach ($defColumn as $col){
						echo $col .",\n";
					} 
				?>
				{name: 'act', index: 'act',label:'Action', width: 40, align: 'center'},				
			],
			gridview: true,
			rownumbers: false,
			rowNum: 10,
			rowList: [5, 10, 15],
			pager: '#navTblData',
			viewrecords: true,
			caption: 'Department',
			jsonReader : { 
				root:"model",
				repeatitems: false			
			},
			loadComplete:function(data){
				console.log(data);
			},
			gridComplete: function(){ 
				var ids = jQuery("#tblData").getDataIDs(); 
				for(var i=0;i<ids.length;i++){ 
					var cl = ids[i]; 
					var cont = jQuery('#tblData').getCell(cl, 'name');					
					//btnEdit = "<input style='height:22px;width:20px;' type='button' value='E' onclick=jQuery('#rowed2').editRow("+cl+"); ></ids>"; 
					//btnDelete = "<input style='height:20px;width:20px;' type='button' value='S' onclick=jQuery('#rowed2').saveRow("+cl+"); />"; 
					btnEdit = "<img title='edit' class='imgBtn' style='height:20px;width:20px;' src='images/action/Sign-Select-icon.png' onclick='returnResultObject(" + cl + ",\"" + cont + "\")' />"; 
					jQuery("#tblData").setRowData(ids[i],{act:btnEdit}) 
				} 
			},
			ondblClickRow: function(){
				var row_id = $("#tblData").getGridParam('selrow');
				var row = $("#tblData").jqGrid('getRowData',row_id);
				returnResultObject(row);
			},
		});
		$("#tblData").jqGrid('navGrid','#navTblData',{add:false,edit:false,search:false,del:false,refresh:false});
		
		//add search text
		$("#tblData").jqGrid('addSearchText',<?php echo $searchBy; ?>);
	});
</script>

<div style="margin-top:20px">
	
	<h1 style="text-align:right"><?php echo $title;?></h1>
	
	<table id="tblData"><tr></tr></table>
	<div id="navTblData"></div>
	<input type="button" style="width:100%" value="<?php echo Yii::t("label","Batal");?>" onClick="window.close()" />
</div>